from rest_framework import serializers
from .models import Drivinginfo
from .models import DrivingMode
from .models import LogisticsMode
from .models import DataDescription
from .models import BasicInfo
from .models import WorkingPlace
from .models import LoadFile
from .models import LoadPicture


class DrivinginfoSerializer(serializers.ModelSerializer):
    class Meta:
        model = Drivinginfo
        fields = '__all__'


class DrivingModeSerializer(serializers.ModelSerializer):
    class Meta:
        model = DrivingMode
        fields = '__all__'


class LogisticsModeSerializer(serializers.ModelSerializer):
    class Meta:
        model = LogisticsMode
        fields = '__all__'


class GPSSerializer(serializers.ModelSerializer):
    class Meta:
        model = Drivinginfo
        fields = ('longitude', 'latitude')


class DataDescriptionSerializer(serializers.ModelSerializer):
    class Meta:
        model = DataDescription
        fields = ('mean', 'median', 'count', 'year', 'month', 'refresh_time')


class BasicInfoSerializer(serializers.ModelSerializer):
    class Meta:
        model = BasicInfo
        fields = ('vin',)


class FuelInfoSerializer(serializers.ModelSerializer):
    class Meta:
        model = Drivinginfo
        fields = ('vin', 'data_time', 'car_speed', 'engine_speed', 'fuel_consumption_pre', 'engine_status')


class WorkingPlaceSerializer(serializers.ModelSerializer):
    vin = serializers.CharField(source='basic_info.vin')

    class Meta:
        model = WorkingPlace
        fields = ('longitude', 'latitude', 'max_word', 'max_tag', 'nearest_site', 'vin')


class LoadFileSerializer(serializers.ModelSerializer):
    class Meta:
        model = LoadFile
        fields = '__all__'


class LoadPictureSerializer(serializers.ModelSerializer):
    class Meta:
        model = LoadPicture
        fields = '__all__'
